package com.example.sys.invoice.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.example.core.controller.BaseController;
import com.example.core.enums.TimeEnums;
import com.example.core.utils.QueryWrapperUtils;
import com.example.core.utils.StringUtils;
import com.example.sys.invoice.service.SysInvoiceService;
import com.example.sys.invoice.vo.SysInvoiceVo;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RequestMapping(value = "sysInvoice")
@RestController
public class SysInvoiceController extends BaseController<SysInvoiceService, SysInvoiceVo> {

    @Override
    public QueryWrapper changeFindPageQueryWrapper(SysInvoiceVo vo) {
        QueryWrapper queryWrapper = super.changeFindPageQueryWrapper(vo);
        if (StringUtils.isNotEmpty(vo.getTime())) {
            QueryWrapperUtils.buildTimeQuery(TimeEnums.valueBy(vo.getTime()), queryWrapper);
        }
        if (StringUtils.isNotEmpty(vo.getStatus())) {
            queryWrapper.eq("status", vo.getStatus());
        }
        return queryWrapper;
    }
}
